﻿//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Manageability;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Manageability.Adm;
using EntLibContrib.Query.Properties;

namespace EntLibContrib.Query.Configuration.Manageability.Commands
{
	/// <summary>
	/// Represents the behavior required to provide Group Policy updates and to publish the
	/// <see cref="ConfigurationSetting"/> instances associated to a <see cref="CustomCommandData"/>.
	/// </summary>
	/// <typeparam name="T"></typeparam>
	public abstract class CustomCommandDataManageabilityProvider<T>
		: ConfigurationElementManageabilityProviderBase<T>
		where T : CustomCommandData
	{
		#region Constants
		/// <summary>
		/// Name for the command type property.
		/// </summary>
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
		public const string CommandTypeKeyName = "commandType";
		#endregion

		#region Properties
		/// <summary>
		/// Gets the template for the name of the policy associated to the object.
		/// </summary>
		protected sealed override string ElementPolicyNameTemplate
		{
			get { return InternalResources.CommandPolicyNameTemplate; }
		}
		#endregion

		#region Protected Static methods
		/// <summary>
		/// Adds the part to edit the policy overrides for the command type of a custom command to the content
		/// built by the <paramref name="contentBuilder"/>.
		/// </summary>
		/// <param name="contentBuilder">The builder for the content where the part will be added.</param>
		/// <param name="configurationObject">The configuration object.</param>
		/// <param name="elementPolicyKeyName">Name of the element policy key.</param>
		protected internal static void AddCommandTypePart(AdmContentBuilder contentBuilder,
																											T configurationObject,
																											string elementPolicyKeyName)
		{
			contentBuilder.AddEditTextPart(InternalResources.CustomCommandCommandTypePartName,
																		elementPolicyKeyName,
																		CommandTypeKeyName,
																		configurationObject.CommandTypeName,
																		1024,
																		true);
		}
		#endregion
	}
}
